package cn.edu.zafu.bigdata.smj.d;

import java.io.*;
import java.net.*;

public class MyServer {
    public static void main(String[] args) {
        try {
            int port = 9990;

            ServerSocket server = new ServerSocket(port);
            Socket socket = server.accept();


            PrintWriter out = new PrintWriter(socket.getOutputStream());
            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

            BufferedReader sin = new BufferedReader(new InputStreamReader(System.in));

            String s;
            while (!(s= in.readLine()).equals("bye")){
                System.out.println("Receive form MyClient: "+s);
                out.println(sin.readLine());
                out.flush();

            }// 循环直到用户输入"bye"

            System.out.println("The connection is closing.");
            in.close();
            out.close();
            socket.close();
            server.close();
        } catch (Exception e) {
            System.out.println("Error: "+e);
        }
    }
}
